<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");

if(isset($arcID))
{
	$cid = $arcID;
}
$arcID = $cid = (isset($cid) && is_numeric($cid)) ? $cid : 0;
if($cid==0)
{
	die(" Request Error! ");
}

$row = $dsql->GetOne("Select * From `#@__memad` where cid='$cid' ");
$adall = $adbody = $adurl = '';
$ntime = time();
	if($ntime>$row['endtime'] || $ntime<$row['starttime'])
	{
		$adbody = $row['expbody'];
		$adurl = $row['expurl'];
	}
	else if($row['normbody']==""){
		$adbody = $row['expbody'];
		$adurl = $row['expurl'];
	}
	else{
		$adbody = $row['normbody'];
		$adurl = $row['normurl'];
		
	}
if($row['adtype']!=0){
   if($row['adtype']==2)
	{
		if($row['expbody']=="" && $row['normbody']==""){
		$adall = "该图片广告位正在出售且暂无备用内容显示！";
		}
		else {
			$adall = "<a href='".$adurl."' target=_blank ><img src='".$adbody."' style='border:none; text-decoration:none;'/></a>";
		}
	}
	else if($row['adtype']==3)
	{
		if($row['expbody']=="" && $row['normbody']==""){
		$adall = "该Flash广告位正在出售且暂无备用内容显示！";
		}
		else {
			$adall = "<embed src='".$adbody."' style='border:none;'/></embed>";
		}
	}
	else
	{
		if($row['expbody']=="" && $row['normbody']==""){
		$adall = "该文字广告位正在出售且暂无备用内容显示！";
		}
		else {
		//$adall = "<a href='".$adurl."' target=_blank style='font-size:12px; color:#333;'>".$adbody."</a>";
		$adall = "<a href='".$adurl."' target=_blank class='text-danger'>".$adbody."</a>";
		}
	}
}
$adall = str_replace('"','\"',$adall);
$adall = str_replace("\r","\\r",$adall);
$adall = str_replace("\n","\\n",$adall);
echo "<!--\r\n";
echo "document.write(\"{$adall}\");\r\n";
echo "-->\r\n";
?>